<template>
  <el-collapse style="border: none" v-model="active">
    <el-collapse-item name="1">
      <template slot="title">
        <div class="collapse-title">
          <span class="header-text">{{ title }}</span>
          <i class="header-icon el-icon-arrow-down" :class="isActive"></i></div>
      </template>
      <div>
        <slot name="content"></slot>
      </div>
    </el-collapse-item>
  </el-collapse>
</template>

<script>
import _ from 'lodash'

export default {
  name: "Collapse",
  data() {
    return {
      active: ['1']
    }
  },
  props: {
    title: {
      type: String,
      required: true
    }
  },
  computed: {
    isActive() {
      if (_.isEqual(this.active, ['1'])) return ''
      else return 'rotate'
    }
  }
}
</script>

<style scoped lang="less">
/deep/ .el-collapse-item__header {
  border-bottom: none;
}

/deep/ .el-collapse-item__wrap {
  border-bottom: none;
}

/deep/ .el-collapse-item__arrow {
  display: none;
}

.collapse-title {
  user-select: none;

  .header-text {
    font-size: 18px;
    font-weight: bold;
    border-left: 5px solid #409EFF;
    padding-left: 5px;
  }

  .header-icon {
    margin-left: 10px;
    font-size: 18px;
    transition: all 0.25s linear;
  }
}

.rotate {
  transform: rotate(180deg);
}
</style>
